//
//  SlideTabBarView.m
//  SlideTabBar
//
//  Created by Mr.LuDashi on 15/6/25.
//  Copyright (c) 2015年 李泽鲁. All rights reserved.
//

#import "SlideTabBarView.h"
#import "SearchProjectInfoVC.h"//找项目
#import "SearchPriceDetail.h"//找资金
#import "BusinessActInfo.h"//活动
#import "RecruitmentInfo.h"//招聘
#import "thirdPersonVC.h"//个人或企业详情
#import "serviceInfo.h"//服务
#import "TrickTenderInfo.h"
#import "searchContactsCell.h"//个人、企业、政府cell
#import "SearchProjectCell.h"
#import "SearchPriceCell.h"
#import "BusinessActCell.h"
#import "RecruitmentShowCell.h"
#import "UsedTool.h"
#import "SoftwareCell.h"
#import "SoftEnterpriseCell.h"


//支付头文件
#import "LSBecomeVIPVC.h"
#import "LSRechargeVC.h"
#import "ForgetPassWord.h"
#import "LSPayResultVC.h"




static NSString * serchContactscell = @"searchContactsCell";
static NSString * SearchProjectcell = @"SearchProjectCell";
static NSString * SearchPricecell = @"SearchPriceCell";
static NSString * BusinessActcell = @"BusinessActCell";
static NSString * Recruitmentcell = @"RecruitmentCell";
static NSString * Softwarecell = @"SoftwareCell";
static NSString * SoftEnterprisecell = @"SoftEnterpriseCell";
#define TOPHEIGHT 60
@interface SlideTabBarView()<UIScrollViewDelegate,UITableViewDataSource,UITableViewDelegate>
{
    BOOL nibsRegistered;
    
    NSString * seguStr;
    NSString * or_Number;
    BOOL  isSetPayPass;
    NSString * projectId;
    double price;
}

///@brife 整个视图的大小
@property (assign) CGRect mViewFrame;

///@brife 下方的ScrollView
@property (strong, nonatomic) UIScrollView *scrollView;

///@brife 上方的按钮数组
@property (strong, nonatomic) NSMutableArray *topViews;

///@brife 下方的表格数组
@property (strong, nonatomic) NSMutableArray *scrollTableViews;

///@brife TableViews的数据源
@property (strong, nonatomic) NSMutableArray *dataSource;

///@brife 当前选中页数
@property (assign) NSInteger currentPage;

///@brife 下面滑动的View
@property (strong, nonatomic) UIView *slideView;

///@brife 上方的ScrollView
@property (strong, nonatomic) UIScrollView *topScrollView;

///@brife 上方的view
@property (strong, nonatomic) UIView *topMainView;

@property (strong, nonatomic) NSMutableArray *muArySaveBtn;

@property (assign, nonatomic) NSInteger paggge;

@property (strong, nonatomic) UIViewController *mainVC;


//支付
@property (strong, nonatomic) NSString * isProjectOrPrice;

@property (strong, nonatomic) LSPromptAlertVC * LSPromptAlert;


@end

@implementation SlideTabBarView
- (LSPromptAlertVC *)LSPromptAlert{
    if (!_LSPromptAlert) {
        _LSPromptAlert = [[LSPromptAlertVC alloc] init];
    }
    return _LSPromptAlert;
}
@synthesize paggge;







-(instancetype)initWithFrame:(CGRect)frame WithCount: (NSInteger) count WithVC:(UIViewController *)vc
{
    
    
    self = [super initWithFrame:frame];
    
    if (self) {
        _mainVC = vc;
        _mViewFrame = frame;
        _tabCount = count;
        _topViews = [[NSMutableArray alloc] init];
        _scrollTableViews = [[NSMutableArray alloc] init];
        _muArySaveBtn = [NSMutableArray array];
        
        _dataSource = [NSMutableArray array];
        
        
        [self initScrollView];
        
        [self initTopTabs];
        
        [self initDownTables];
        
        
        [self initSlideView];
/******************************支付*********************************/
        //监听按钮
        [self.LSPromptAlert.PromptAlertView.becomeVIPBtn addTarget:self action:@selector(clickBecomeVIPBtn) forControlEvents:UIControlEventTouchUpInside];
        
        [self.LSPromptAlert.PromptAlertView.alipayBtn addTarget:self action:@selector(clickAlipayBtn) forControlEvents:UIControlEventTouchUpInside];
        
        [self.LSPromptAlert.PromptAlertView.balancePayBtn addTarget:self action:@selector(clickCashBtn) forControlEvents:UIControlEventTouchUpInside];
        
        //支付回调通知
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(presentView) name:@"alipayResult" object:nil];
        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(presentFailedView) name:@"alipayFailed" object:nil];
/**********************************************************************/
    }
    
    return self;
}




#pragma mark -- 初始化滑动的指示View
-(void) initSlideView{
    
    CGFloat width = _mViewFrame.size.width / 6;
    
    if(self.tabCount <=6){
        width = _mViewFrame.size.width / self.tabCount;
    }

    _slideView = [[UIView alloc] initWithFrame:CGRectMake(0, TOPHEIGHT - 1, width, 1)];
    [_slideView setBackgroundColor:[UIColor colorWithRed:32/255.f green:165/255.f blue:240/255.f alpha:1.f]];
    [_topScrollView addSubview:_slideView];
}


#pragma mark -- 初始化表格的数据源
-(void) initDataSource{
    _dataSource = [[NSMutableArray alloc] initWithCapacity:_tabCount];
    
    for (int i = 1; i <= _tabCount; i ++) {
        
        NSMutableArray *tempArray  = [[NSMutableArray alloc] initWithCapacity:20];
        
        for (int j = 1; j <= 20; j ++) {
            
            NSString *tempStr = [NSString stringWithFormat:@"我是第%d个TableView的第%d条数据。", i, j];
            [tempArray addObject:tempStr];
        }
        
        [_dataSource addObject:tempArray];
    }
}


#pragma mark -- 实例化ScrollView
-(void) initScrollView{
    _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, _mViewFrame.origin.y, _mViewFrame.size.width, _mViewFrame.size.height - TOPHEIGHT)];
    _scrollView.contentSize = CGSizeMake(_mViewFrame.size.width * _tabCount, _mViewFrame.size.height - 60);
    _scrollView.backgroundColor = [UIColor whiteColor];
    
    _scrollView.pagingEnabled = YES;
    
    _scrollView.delegate = self;
    [self addSubview:_scrollView];
    
    
}



#pragma mark -- 实例化顶部的tab
-(void) initTopTabs{
    CGFloat width = _mViewFrame.size.width / 6;
    
    if(self.tabCount <=6){
        width = _mViewFrame.size.width / self.tabCount;
    }
    
    _topMainView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, _mViewFrame.size.width, TOPHEIGHT)];
    
    _topScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, _mViewFrame.size.width, TOPHEIGHT)];
    
    _topScrollView.showsHorizontalScrollIndicator = NO;
    
    _topScrollView.showsVerticalScrollIndicator = YES;
    
//    _topScrollView.bounces = NO;
    
    _topScrollView.delegate = self;
    

    
    _topScrollView.contentSize = CGSizeMake(width * _tabCount, TOPHEIGHT);
    [self addSubview:_topMainView];
    
    [_topMainView addSubview:_topScrollView];
    
    UIView *viewBack = [[UIView alloc] initWithFrame:(CGRect){0,TOPHEIGHT-10,320,10}];
    viewBack.backgroundColor = [UIColor colorWithWhite:0.8f alpha:1.f];
    [_topMainView addSubview:viewBack];
    
    
    
    NSArray *aryTitle = [NSArray array];
    if ([[USER_DEFAULTS objectForKey:@"usertype"] integerValue] ==1 ) {//个人
        aryTitle = @[@"个人",@"企业",@"政府",@"项目",@"资金",@"服务",@"招聘",@"活动",@"招标"];
    }else if([[USER_DEFAULTS objectForKey:@"usertype"] integerValue] ==2 ){//企业
        aryTitle = @[@"个人",@"企业",@"政府",@"项目",@"资金",@"服务",@"活动",@"招标"];
    }else {
       aryTitle = @[@"个人",@"企业",@"政府",@"项目",@"资金",@"服务",@"活动",@"招标"];
    }
    
    for (int i = 0; i < _tabCount; i ++) {

        UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(i * width, 0, width, TOPHEIGHT)];
        button.tag = i;
        [button setTitle:aryTitle[i] forState:UIControlStateNormal];
        [button addTarget:self action:@selector(tabButton:) forControlEvents:UIControlEventTouchUpInside];
        [button setTitleColor:[UIColor colorWithRed:89/255.f green:87/255.f blue:87/255.f alpha:1.f] forState:UIControlStateNormal];
        button.titleLabel.font = [UIFont systemFontOfSize:13.f];
//        [view addSubview:button];
        
        [_muArySaveBtn addObject:button];
        [_topViews addObject:button];
        [_topScrollView addSubview:button];
    }
}



#pragma mark --点击顶部的按钮所触发的方法
-(void) tabButton: (UIButton *) sender
{

    CABasicAnimation *anim = [CABasicAnimation animation];
    anim.keyPath = @"transform.scale";
    anim.toValue = @1.5;
    anim.repeatCount = 1;
    anim.duration = 0.1;
    anim.autoreverses = YES;
    [sender.layer addAnimation:anim forKey:nil];

    
    _dataSource = nil;
    _currentPage = sender.tag;
    [self updateTableWithPageNumber:_currentPage];
    //顶部跟着滑动
    [_topScrollView scrollRectToVisible:CGRectMake(sender.frame.origin.x-sender.frame.size.width*2, 0, _topScrollView.frame.size.width, _topScrollView.frame.size.height) animated:YES];
    [_scrollView setContentOffset:CGPointMake(sender.tag * _mViewFrame.size.width, 0) animated:YES];
}

#pragma mark --初始化下方的TableViews
-(void) initDownTables{
    
    for (int i = 0; i < 2; i ++) {
        
        UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(i * _mViewFrame.size.width, 0, _mViewFrame.size.width, _mViewFrame.size.height - TOPHEIGHT - 64)];
        tableView.delegate = self;
        tableView.dataSource = self;
        tableView.tag = i;
        tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        tableView.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
            paggge = 1;
            [self startSearch];
            NSString *path = [[NSBundle mainBundle]pathForResource:@"refresh"
                                                            ofType:@"wav"];
            SystemSoundID soundID;
            AudioServicesCreateSystemSoundID((__bridge CFURLRef)[NSURL fileURLWithPath:path], &soundID);
            AudioServicesPlaySystemSound(soundID); //仅播放音频
        }];
        
        tableView.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
            paggge += 1;
            [self startSearch];
        }];
        
        tableView.mj_footer.hidden = YES;
        
        if (i == 0) {
            // 马上进入刷新状态
            [tableView.mj_header beginRefreshing];
        }
        
        [_scrollTableViews addObject:tableView];
        [_scrollView addSubview:tableView];
    }
    
}


#pragma mark --根据scrollView的滚动位置复用tableView，减少内存开支
-(void) updateTableWithPageNumber: (NSUInteger) pageNumber{
    int tabviewTag = pageNumber % 2;
    
    CGRect tableNewFrame = CGRectMake(pageNumber * _mViewFrame.size.width, 0, _mViewFrame.size.width, _mViewFrame.size.height - TOPHEIGHT - 64);
    
    UITableView *reuseTableView = _scrollTableViews[tabviewTag];
    reuseTableView.frame = tableNewFrame;
    // 马上进入刷新状态
    //[reuseTableView.mj_header beginRefreshing];
    [self startSearch];
    [reuseTableView reloadData];
}




#pragma mark -- scrollView的代理方法

-(void) modifyTopScrollViewPositiong: (UIScrollView *) scrollView{
    
    if (scrollView == _scrollView) {
        UIButton *sender = _muArySaveBtn[_currentPage];
        //顶部跟着滑动
        [_topScrollView scrollRectToVisible:CGRectMake(sender.frame.origin.x-sender.frame.size.width*2, 0, _topScrollView.frame.size.width, _topScrollView.frame.size.height) animated:YES];
    }

}

///拖拽后调用的方法
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
{
    [self modifyTopScrollViewPositiong:scrollView];
}



-(void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView
{
//    [self scrollViewDidEndDecelerating:scrollView];
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    if ([scrollView isEqual:_scrollView]) {
        _currentPage = _scrollView.contentOffset.x/_mViewFrame.size.width;
        
        _currentPage = _scrollView.contentOffset.x/_mViewFrame.size.width;
        
        //    UITableView *currentTable = _scrollTableViews[_currentPage];
        //    [currentTable reloadData];
        
        [self updateTableWithPageNumber:_currentPage];

        return;
    }
    //顶部跟着动
    [self modifyTopScrollViewPositiong:scrollView];
}

-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
    if ([_scrollView isEqual:scrollView]) {
        CGRect frame = _slideView.frame;
        
        if (self.tabCount <= 6) {
             frame.origin.x = scrollView.contentOffset.x/_tabCount;
        } else {
             frame.origin.x = scrollView.contentOffset.x/6;
            
        }
        
       
        _slideView.frame = frame;
    }
    
}





#pragma mark -- talbeView的代理方法
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}

-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    [tableView tableViewDisplayWitMsg:@"没有查询到相对应的数据" ifNecessaryForRowCount:_dataSource.count];
    return _dataSource.count;
}

-(CGFloat) tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if ([[USER_DEFAULTS objectForKey:@"usertype"] integerValue] ==1 ) {
        if (_currentPage < 3) {//个人信息
            return 80;
        }else if (_currentPage == 3) {//项目
            return 103;
        }else if (_currentPage == 4) {//资金
            return 145;
        }else if (_currentPage == 5) {//服务
            return 142;
        }else if (_currentPage == 6) {//招聘
            return 110;
        }else if (_currentPage == 7) {//活动
            return 157;
        }else{                        //招标
            return 103;
        }
    }else{
        if (_currentPage < 3) {//个人信息
            return 80;
        }else if (_currentPage == 3) {//项目
            return 110;
        }else if (_currentPage == 4) {//资金
            return 145;
        }else if (_currentPage == 5) {//服务
            return 142;
        }else if (_currentPage == 6) {//活动
            return 157;
        }else{
            return 103;               //招标
        }
    }
    return 0;
}

-(UITableViewCell *)tableView:tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{  
    if ([[USER_DEFAULTS objectForKey:@"usertype"] integerValue] == 1 ) {//个人
        if (_currentPage < 3) {//个人信息
            searchContactsCell *cell = [tableView dequeueReusableCellWithIdentifier:serchContactscell];
            if (!cell) {
                UINib * nib = [UINib nibWithNibName:@"searchContactsCell" bundle:nil];
                [tableView registerNib:nib forCellReuseIdentifier:serchContactscell];
                cell = [tableView dequeueReusableCellWithIdentifier:serchContactscell];
            }
            
            NSDictionary * dict = _dataSource[indexPath.row];
            
            cell.lineView.hidden = YES;
            
            [cell.headImg sd_setImageWithURL:[NSURL URLWithString:dict[@"headPhoto"]]];
            [cell.headImg.layer setCornerRadius:(cell.headImg.frame.size.height/2)];
            [cell.headImg.layer setMasksToBounds:YES];
            [cell.headImg setContentMode:UIViewContentModeScaleAspectFill];
            [cell.headImg setClipsToBounds:YES];
            cell.headImg.layer.shadowColor = [UIColor whiteColor].CGColor;
            cell.headImg.layer.shadowOffset = CGSizeMake(4, 4);
            cell.headImg.layer.shadowOpacity = 0.5;
            cell.headImg.layer.shadowRadius = 2.0;
            
            if ([dict[@"userName"] isEqualToString:@""] || [dict[@"userName"] isEqualToString:@"null"]) {
                cell.nameLabel.text = dict[@"account"];
            }else{
                cell.nameLabel.text = dict[@"userName"];
            }
            
//            NSString *str = cell.nameLabel.text;
//            NSInteger with = 0;
//            for(int i=0; i< [str length];i++){
//                NSRange range = NSMakeRange(i, 1);
//                NSString *subString = [str substringWithRange:range];
//                const char    *cString = [subString UTF8String];
//                if (strlen(cString) == 3)
//                {
//                    
//                    with = with + subString.length * 16;
//                    
//                    
//                }else{
//                    
//                    with = with + subString.length * 12;
//                    
//                }
//            }
            CGSize size = [cell.nameLabel sizeThatFits:CGSizeMake(MAXFLOAT, 21)];
            [cell.nameLabel setFrame:CGRectMake(cell.nameLabel.x, cell.nameLabel.y, size.width, cell.nameLabel.height)];
            
            
            //    cell.nameLabel.width = cell.nameLabel.text.length * 16;
            cell.lineView.x = cell.nameLabel.x + cell.nameLabel.width + 5;
            
            if ([dict[@"positionName"] isEqualToString:@""] || [dict[@"positionName"] isEqualToString:@"null"]) {
                cell.posName.text = @"";
            }else{
                cell.posName.text = dict[@"positionName"];
            }
            CGSize posSize = [cell.posName sizeThatFits:CGSizeMake(MAXFLOAT, 21)];
            [cell.posName setFrame:CGRectMake(cell.lineView.x, cell.posName.y, posSize.width, cell.posName.height)];

            cell.vImg.x = cell.posName.x + cell.posName.width + 2;
            
            //判断上级
            if (_currentPage == 0) { //个人
                cell.detailLabel.text = [UsedTool userType:@"1" companyName:dict[@"companyName"] userAddress:dict[@"userAddress"]];
            }else if(_currentPage == 1){//企业
                cell.detailLabel.text = [UsedTool userType:@"2" companyName:dict[@"companyName"] userAddress:dict[@"userAddress"]];
            }else if(_currentPage == 2){//政府
                cell.detailLabel.text = [UsedTool userType:@"3" companyName:dict[@"companyName"] userAddress:dict[@"userAddress"]];
            }

            //认证图标
//            if ([dict[@"authState"]integerValue] != 2) {
//                cell.vImg.image = [UIImage imageNamed:@"weirenzheng"];
//            }else if ([dict[@"authState"]integerValue] == 2){
//                cell.vImg.image = [UIImage imageNamed:@"yirenzheng"];
//            }
            //认证
            cell.isAuthState.hidden = [UsedTool authStateImageViewHidden:dict[@"authState"]];
            //会员图标
            cell.vImg.image = [UsedTool setVipimage:dict[@"vipLevel"]];
            return cell;
        }else if (_currentPage == 3){//项目
            SearchProjectCell *cell = [tableView dequeueReusableCellWithIdentifier:SearchProjectcell];
            if (!cell) {
                UINib * nib = [UINib nibWithNibName:@"SearchProjectCell" bundle:nil];//项目
                [tableView registerNib:nib forCellReuseIdentifier:SearchProjectcell];
                cell = [tableView dequeueReusableCellWithIdentifier:SearchProjectcell];
            }
            cell.TitleLabel.text = _dataSource[indexPath.row][@"title"];
            
            cell.AddressLabel.text = _dataSource[indexPath.row][@"address"];
            
            cell.IndustryLabel.text = _dataSource[indexPath.row][@"industry"];
            cell.PriceLabel.text = [self comperNumber:_dataSource[indexPath.row][@"investment"]];
            if ([_dataSource[indexPath.row][@"type"] isEqualToString:@"政府"]) {
                
                cell.ProjectIconImageView.image = [UIImage imageNamed:@"政府"];
            }else if ([_dataSource[indexPath.row][@"type"] isEqualToString:@"企业"]){
                
                cell.ProjectIconImageView.image = [UIImage imageNamed:@"企业"];
            }else{
                
                cell.ProjectIconImageView.image = [UIImage imageNamed:@"个人"];
            }
            return cell;
        }else if (_currentPage == 4){//资金
            SearchPriceCell *cell = [tableView dequeueReusableCellWithIdentifier:SearchPricecell];
            if (!cell) {
                UINib * nib1 = [UINib nibWithNibName:@"SearchPriceCell" bundle:nil];//资金
                [tableView registerNib:nib1 forCellReuseIdentifier:SearchPricecell];
                cell = [tableView dequeueReusableCellWithIdentifier:SearchPricecell];
            }
            NSDictionary *dic = _dataSource[indexPath.row];
            
            //设置圆形头像
            [cell.headPhoto.layer setCornerRadius:cell.headPhoto.frame.size.height/2];
            [cell.headPhoto.layer setMasksToBounds:YES];
            [cell.headPhoto setContentMode:UIViewContentModeScaleAspectFill];
            [cell.headPhoto setClipsToBounds:YES];
            cell.headPhoto.layer.shadowColor = [UIColor blackColor].CGColor;
            cell.headPhoto.layer.shadowOffset = CGSizeMake(4, 4);
            cell.headPhoto.layer.shadowOpacity = 0.5;
            cell.headPhoto.layer.shadowRadius = 2.0;
            cell.headPhoto.userInteractionEnabled = YES;
            
            [cell.headPhoto sd_setImageWithURL:dic[@"headPhoto"] placeholderImage:[UIImage imageNamed:@"20100403114758394_4147"]];
            
            
            
            cell.commentUserName.text = dic[@"username"];
            if (dic[@"username"]==nil || [dic[@"username"] isEqualToString:@""] || [dic[@"username"] isEqualToString:@"null"]) {
                cell.commentUserName.text = dic[@"account"];
            }
            
            
            
            if (dic[@"posiTionName"]==nil||[dic[@"posiTionName"] isEqualToString:@"null"]) {
                cell.posiTion.text = @"";
            }else{
                cell.posiTion.text = dic[@"posiTionName"];
            }
            
//            if ([dic[@"authState"] integerValue] == 2) {
//                
//                cell.authStateImageView.image = [UIImage imageNamed:@"yirenzheng"];
//            }else{
//                
//                cell.authStateImageView.image = [UIImage imageNamed:@"weirenzheng"];
//            }
            //认证
            cell.isAuthState.hidden = [UsedTool authStateImageViewHidden:dic[@"authState"]];
            //会员图标
            cell.authStateImageView.image = [UsedTool setVipimage:dic[@"vipLevel"]];
            cell.titleLabel.text = dic[@"title"];
            
            cell.priceLabel.text = [self comperNumber:dic[@"investment"]];
            
            
            
            //判断上级
            cell.companyUserName.text = [UsedTool userType:dic[@"userType"] companyName:dic[@"companyName"] userAddress:dic[@"userAddress"]];

            
            return cell;
        }else if (_currentPage == 5){//服务
            
            NSDictionary *dicData = _dataSource[indexPath.row];
            
            if ([dicData[@"userType"] integerValue] == 2) {
                
                //企业
                SoftEnterpriseCell *cell = [tableView dequeueReusableCellWithIdentifier:SoftEnterprisecell];
                if (!cell) {
                    UINib * nib4 = [UINib nibWithNibName:@"SoftEnterpriseCell" bundle:nil];//服务
                    [tableView registerNib:nib4 forCellReuseIdentifier:SoftEnterprisecell];
                    cell = [tableView dequeueReusableCellWithIdentifier:SoftEnterprisecell];
                }
                cell.titleLabel.text = dicData[@"title"];
                //设置圆形头像
                [cell.headPhoto.layer setCornerRadius:cell.headPhoto.frame.size.height/2];
                [cell.headPhoto.layer setMasksToBounds:YES];
                [cell.headPhoto setContentMode:UIViewContentModeScaleAspectFill];
                [cell.headPhoto setClipsToBounds:YES];
                cell.headPhoto.layer.shadowColor = [UIColor blackColor].CGColor;
                cell.headPhoto.layer.shadowOffset = CGSizeMake(4, 4);
                cell.headPhoto.layer.shadowOpacity = 0.5;
                cell.headPhoto.layer.shadowRadius = 2.0;
                cell.headPhoto.userInteractionEnabled = YES;
                [cell.headPhoto sd_setImageWithURL:dicData[@"headPhoto"] placeholderImage:[UIImage imageNamed:@"project_detail_taoxin_normal"]];
                
                cell.addressLabel.text = dicData[@"address"];
                
                
                //自定义的label
                UILabel *label = [[UILabel alloc] init];
                if (dicData[@"username"] == nil ||[dicData[@"username"] isEqualToString:@""]||[dicData[@"username"] isEqualToString:@"null"]) {
                    label.text = dicData[@"account"];
                }else{
                    label.text = dicData[@"username"];
                }
                label.numberOfLines = 1;
                label.font = [UIFont systemFontOfSize:17];
                label.textColor = cell.companyName.textColor;
                CGSize size = [label.text sizeWithFont:[UIFont systemFontOfSize:17] constrainedToSize:CGSizeMake(MAXFLOAT, 21)];
                if (size.width > self.width-140) {
                    size.width = self.width-140;
                }
                
                CGRect frameC = cell.companyName.frame;
                frameC.size.width = size.width;
                label.frame = frameC;
                [cell addSubview:label];
                
                UIImageView *authImageView = [[UIImageView alloc] initWithFrame:CGRectMake(label.frame.origin.x+label.frame.size.width+8, label.frame.origin.y+3, 17, 14)];
                
                
//                if ([dicData[@"authState"] integerValue] == 2) {
//                    //已认证
//                    authImageView.image = [UIImage imageNamed:@"yirenzheng"];
//                }else{
//                    
//                    authImageView.image = [UIImage imageNamed:@"weirenzheng"];
//                }
                //认证
                cell.isAuthState.hidden = [UsedTool authStateImageViewHidden:dicData[@"authState"]];
                //会员图标
                authImageView.image = [UsedTool setVipimage:dicData[@"vipLevel"]];
                [cell addSubview:authImageView];
                
                return cell;
            }else{
                //个人
                SoftwareCell *cell = [tableView dequeueReusableCellWithIdentifier:Softwarecell];
                if (!cell) {
                    UINib * nib3 = [UINib nibWithNibName:@"SoftwareCell" bundle:nil];//服务
                    [tableView registerNib:nib3 forCellReuseIdentifier:Softwarecell];
                    cell = [tableView dequeueReusableCellWithIdentifier:Softwarecell];
                }
    
                cell.titleLabel.text =dicData[@"title"];
                
                
                //设置圆形头像
                [cell.headPhotoImageView.layer setCornerRadius:cell.headPhotoImageView.frame.size.height/2];
                [cell.headPhotoImageView.layer setMasksToBounds:YES];
                [cell.headPhotoImageView setContentMode:UIViewContentModeScaleAspectFill];
                [cell.headPhotoImageView setClipsToBounds:YES];
                cell.headPhotoImageView.layer.shadowColor = [UIColor blackColor].CGColor;
                cell.headPhotoImageView.layer.shadowOffset = CGSizeMake(4, 4);
                cell.headPhotoImageView.layer.shadowOpacity = 0.5;
                cell.headPhotoImageView.layer.shadowRadius = 2.0;
                cell.headPhotoImageView.userInteractionEnabled = YES;
                
                [cell.headPhotoImageView sd_setImageWithURL:dicData[@"headPhoto"] placeholderImage:[UIImage imageNamed:@"project_detail_taoxin_normal"]];
                
                if (dicData[@"username"] == nil ||[dicData[@"username"] isEqualToString:@""]||[dicData[@"username"] isEqualToString:@"null"]) {
                    cell.commentUserName.text = dicData[@"account"];
                }else{
                    cell.commentUserName.text = dicData[@"username"];
                }
                
                cell.posiTion.text = dicData[@"posiTionName"];
                if (dicData[@"posiTionName"]==nil||[dicData[@"posiTionName"] isEqualToString:@"null"]) {
                    cell.posiTion.text = @"";
                }
                
//                if ([dicData[@"authState"] integerValue] == 2) {
//                    
//                    cell.authStateImageView.image = [UIImage imageNamed:@"yirenzheng"];
//                }else{
//                    
//                    cell.authStateImageView.image = [UIImage imageNamed:@"weirenzheng"];
//                }
                //认证
                cell.isAuthState.hidden = [UsedTool authStateImageViewHidden:dicData[@"authState"]];
                //会员图标
                cell.authStateImageView.image = [UsedTool setVipimage:dicData[@"vipLevel"]];
                //判断上级
                cell.companyUserName.text = [UsedTool userType:dicData[@"userType"] companyName:dicData[@"companyName"] userAddress:dicData[@"userAddress"]];

                return cell;
            }

        }else if (_currentPage == 6){ //招聘
            
            UINib * nib5 = [UINib nibWithNibName:@"RecruitmentShowCell" bundle:nil];//招聘
            [tableView registerNib:nib5 forCellReuseIdentifier:Recruitmentcell];
            
            
            RecruitmentShowCell *cell = [tableView dequeueReusableCellWithIdentifier:Recruitmentcell];
            
            
            
            NSDictionary *dic = _dataSource[indexPath.row];
//            [cell.logoPhoto setImage:[UIImage imageNamed:@"20100403114758394_4147"]];
//            if (dic[@"photos"]) {
//                [cell.logoPhoto sd_setImageWithURL:[NSURL URLWithString:dic[@"photos"][0]] placeholderImage:[UIImage imageNamed:@"20100403114758394_4147"]];
//            }
            
            
            cell.titleLabel.text = dic[@"positionName"];
            
            
            
            cell.moneyLabel.text = dic[@"money"];
            if (dic[@"money"]==nil||[dic[@"money"] isEqualToString:@"null"]||[dic[@"money"] isEqualToString:@""]||[dic[@"money"] integerValue]==0) {
                cell.moneyLabel.text = @"面议";
            }
            NSRange range = [dic[@"address"] rangeOfString:@"-"];
            cell.cityLabel.text = [dic[@"address"] substringToIndex:range.location];
            
            cell.schoolLabel.text = dic[@"schooling"];
            cell.yearLabel.text = dic[@"experience"];
            cell.addressLabel.text = dic[@"recruitCompany"];
            return cell;

       
        }else if(_currentPage == 7){//活动
            BusinessActCell *cell = [tableView dequeueReusableCellWithIdentifier:BusinessActcell];
            if (!cell) {
                UINib * nib2 = [UINib nibWithNibName:@"BusinessActCell" bundle:nil];//活动
                [tableView registerNib:nib2 forCellReuseIdentifier:BusinessActcell];
                cell = [tableView dequeueReusableCellWithIdentifier:BusinessActcell];
            }
            
            NSDictionary *dicData = [NSDictionary dictionaryWithDictionary:_dataSource[indexPath.row]];
            
            [cell.photoImageView sd_setImageWithURL:[NSURL URLWithString:dicData[@"logo"]] placeholderImage:[UIImage imageNamed:@"img_normal3"]];
            cell.titleLabel.text = dicData[@"title"];
            cell.addressLabel.text = dicData[@"address"];
            //时间
            NSString *timeStr = dicData[@"createtime"];
            //年月日
            NSString *yearStr = [timeStr substringToIndex:10];
            //几点
            NSString *timeString = [timeStr substringWithRange:NSMakeRange(10,6)];
            //周几
            NSString *weekStr = [UsedTool getWeekDayForstring:timeStr];
            
            cell.timeLabel.text = [NSString stringWithFormat:@"%@ %@ %@",yearStr,weekStr,timeString];
            //标签
            NSArray *arrayLabel = [dicData[@"lable"] componentsSeparatedByString:@","];
            if (arrayLabel.count>0) {
                
                cell.labelLabel.layer.borderWidth = 0.5f;
                cell.labelLabel.layer.borderColor = RGB(23, 176, 216).CGColor;
                cell.labelLabel.backgroundColor = RGB(217, 242, 255);
                cell.labelLabel.text = arrayLabel[0];
                CGSize size = [cell.labelLabel sizeThatFits:CGSizeMake(MAXFLOAT, 18)];
                cell.labelWidthConstraint.constant = size.width +10;
                
            }
            if (arrayLabel.count>1) {
                cell.labelLabelTwo.layer.borderWidth = 0.5f;
                cell.labelLabelTwo.layer.borderColor = RGB(23, 176, 216).CGColor;
                cell.labelLabelTwo.backgroundColor = RGB(217, 242, 255);
                cell.labelLabelTwo.text = arrayLabel[1];
                CGSize sizeTwo = [cell.labelLabelTwo sizeThatFits:CGSizeMake(MAXFLOAT, 18)];
                cell.labelWidthConstraintTwo.constant = sizeTwo.width +10;
            }
            if (arrayLabel.count==1) {
                cell.labelLabelTwo.text = @"";
                cell.labelWidthConstraintTwo.constant = 0;
            }
         
            return cell;
            
        }else{//招标
            SearchProjectCell *cell = [tableView dequeueReusableCellWithIdentifier:SearchProjectcell];
            if (!cell) {
                UINib * nib = [UINib nibWithNibName:@"SearchProjectCell" bundle:nil];//项目
                [tableView registerNib:nib forCellReuseIdentifier:SearchProjectcell];
                cell = [tableView dequeueReusableCellWithIdentifier:SearchProjectcell];
            }
            cell.TitleLabel.text = _dataSource[indexPath.row][@"title"];
            
            cell.AddressLabel.text = _dataSource[indexPath.row][@"address"];
            
            cell.IndustryLabel.text = _dataSource[indexPath.row][@"projectType"];
            cell.PriceLabel.textColor = RGB(111, 113, 121);
            //时间换算
            NSDate *date = [CustomExcetion dateFromString:_dataSource[indexPath.row][@"createtime"]];
            [cell.investmentLabel setTextColor:RGB(111, 113, 121)];
            cell.PriceLabel.text = [CustomExcetion prettyDateWithReference:date];

            if ([_dataSource[indexPath.row][@"type"] isEqualToString:@"政府"]) {
                
                cell.ProjectIconImageView.image = [UIImage imageNamed:@"政府"];
            }else if ([_dataSource[indexPath.row][@"type"] isEqualToString:@"企业"]){
                
                cell.ProjectIconImageView.image = [UIImage imageNamed:@"企业"];
            }else{
                
                cell.ProjectIconImageView.image = [UIImage imageNamed:@"个人"];
            }
            return cell;
        }
//========================******************企业 + 政府****************========================================
    }else {
        if (_currentPage < 3) {//个人信息
            searchContactsCell *cell = [tableView dequeueReusableCellWithIdentifier:serchContactscell];
            if (!cell) {
                UINib * nib = [UINib nibWithNibName:@"searchContactsCell" bundle:nil];
                [tableView registerNib:nib forCellReuseIdentifier:serchContactscell];
                cell = [tableView dequeueReusableCellWithIdentifier:serchContactscell];
            }
            
            NSDictionary * dict = _dataSource[indexPath.row];
            
            cell.lineView.hidden = YES;
            
            [cell.headImg sd_setImageWithURL:[NSURL URLWithString:dict[@"headPhoto"]]];
            [cell.headImg.layer setCornerRadius:(cell.headImg.frame.size.height/2)];
            [cell.headImg.layer setMasksToBounds:YES];
            [cell.headImg setContentMode:UIViewContentModeScaleAspectFill];
            [cell.headImg setClipsToBounds:YES];
            cell.headImg.layer.shadowColor = [UIColor whiteColor].CGColor;
            cell.headImg.layer.shadowOffset = CGSizeMake(4, 4);
            cell.headImg.layer.shadowOpacity = 0.5;
            cell.headImg.layer.shadowRadius = 2.0;
            
            if ([dict[@"userName"] isEqualToString:@""] || [dict[@"userName"] isEqualToString:@"null"]) {
                cell.nameLabel.text = dict[@"account"];
            }else{
                cell.nameLabel.text = dict[@"userName"];
            }
            
//            NSString *str = cell.nameLabel.text;
//            NSInteger with = 0;
//            for(int i=0; i< [str length];i++){
//                NSRange range = NSMakeRange(i, 1);
//                NSString *subString = [str substringWithRange:range];
//                const char    *cString = [subString UTF8String];
//                if (strlen(cString) == 3)
//                {
//                    
//                    with = with + subString.length * 16;
//                    
//                    
//                }else{
//                    
//                    with = with + subString.length * 12;
//                    
//                }
//            }
            CGSize size = [cell.nameLabel sizeThatFits:CGSizeMake(MAXFLOAT, 21)];
            [cell.nameLabel setFrame:CGRectMake(cell.nameLabel.x, cell.nameLabel.y, size.width, cell.nameLabel.height)];
            
            
            //    cell.nameLabel.width = cell.nameLabel.text.length * 16;
            cell.lineView.x = cell.nameLabel.x + cell.nameLabel.width + 5;
            
            if ([dict[@"positionName"] isEqualToString:@""] || [dict[@"positionName"] isEqualToString:@"null"]) {
                cell.posName.text = @"";
            }else{
                cell.posName.text = dict[@"positionName"];
            }
            CGSize posSize = [cell.posName sizeThatFits:CGSizeMake(MAXFLOAT, 21)];
            [cell.posName setFrame:CGRectMake(cell.lineView.x, cell.posName.y, posSize.width, cell.posName.height)];
            
            cell.vImg.x = cell.posName.x + cell.posName.width + 2;
//            if ([dict[@"positionName"] isEqualToString:@""] || [dict[@"positionName"] isEqualToString:@"null"]) {
//                cell.posName.text = @"";
//            }
//            
//            cell.posName.width = cell.posName.text.length * 13;
//            cell.posName.x = cell.lineView.x + 3;
//            cell.vImg.x = cell.posName.x + cell.posName.width + 2;
            
            //判断上级
            if(_currentPage == 0){//个人
                cell.detailLabel.text = [UsedTool userType:@"1" companyName:dict[@"companyName"] userAddress:dict[@"userAddress"]];
            }else if(_currentPage == 1){//企业
                cell.detailLabel.text = [UsedTool userType:@"2" companyName:dict[@"companyName"] userAddress:dict[@"userAddress"]];
            }else if(_currentPage == 2){//政府
                cell.detailLabel.text = [UsedTool userType:@"3" companyName:dict[@"companyName"] userAddress:dict[@"userAddress"]];
            }
            

            
//            if ([dict[@"authState"]integerValue] != 2) {
//                cell.vImg.image = [UIImage imageNamed:@"weirenzheng"];
//            }else if ([dict[@"authState"]integerValue] == 2){
//                cell.vImg.image = [UIImage imageNamed:@"yirenzheng"];
//            }
            //认证
            cell.isAuthState.hidden = [UsedTool authStateImageViewHidden:dict[@"authState"]];
            //会员图标
            cell.vImg.image = [UsedTool setVipimage:dict[@"vipLevel"]];
            return cell;
        }else if (_currentPage == 3){//项目
            SearchProjectCell *cell = [tableView dequeueReusableCellWithIdentifier:SearchProjectcell];
            if (!cell) {
                UINib * nib = [UINib nibWithNibName:@"SearchProjectCell" bundle:nil];//项目
                [tableView registerNib:nib forCellReuseIdentifier:SearchProjectcell];
                cell = [tableView dequeueReusableCellWithIdentifier:SearchProjectcell];
            }
            cell.TitleLabel.text = _dataSource[indexPath.row][@"title"];
            
            cell.AddressLabel.text = _dataSource[indexPath.row][@"address"];
            
            cell.IndustryLabel.text = _dataSource[indexPath.row][@"industry"];
            cell.PriceLabel.text = [self comperNumber:_dataSource[indexPath.row][@"investment"]];
            if ([_dataSource[indexPath.row][@"type"] isEqualToString:@"政府"]) {
                
                cell.ProjectIconImageView.image = [UIImage imageNamed:@"政府"];
            }else if ([_dataSource[indexPath.row][@"type"] isEqualToString:@"企业"]){
                
                cell.ProjectIconImageView.image = [UIImage imageNamed:@"企业"];
            }else{
                
                cell.ProjectIconImageView.image = [UIImage imageNamed:@"个人"];
            }
            return cell;
        }else if (_currentPage == 4){//资金
            SearchPriceCell *cell = [tableView dequeueReusableCellWithIdentifier:SearchPricecell];
            if (!cell) {
                UINib * nib1 = [UINib nibWithNibName:@"SearchPriceCell" bundle:nil];//资金
                [tableView registerNib:nib1 forCellReuseIdentifier:SearchPricecell];
                cell = [tableView dequeueReusableCellWithIdentifier:SearchPricecell];
            }
            NSDictionary *dic = _dataSource[indexPath.row];
            
            //设置圆形头像
            [cell.headPhoto.layer setCornerRadius:cell.headPhoto.frame.size.height/2];
            [cell.headPhoto.layer setMasksToBounds:YES];
            [cell.headPhoto setContentMode:UIViewContentModeScaleAspectFill];
            [cell.headPhoto setClipsToBounds:YES];
            cell.headPhoto.layer.shadowColor = [UIColor blackColor].CGColor;
            cell.headPhoto.layer.shadowOffset = CGSizeMake(4, 4);
            cell.headPhoto.layer.shadowOpacity = 0.5;
            cell.headPhoto.layer.shadowRadius = 2.0;
            cell.headPhoto.userInteractionEnabled = YES;
            
            [cell.headPhoto sd_setImageWithURL:dic[@"headPhoto"] placeholderImage:[UIImage imageNamed:@"20100403114758394_4147"]];
            
            
            
            
            if (dic[@"username"]==nil || [dic[@"username"] isEqualToString:@""] || [dic[@"username"] isEqualToString:@"null"]) {
                cell.commentUserName.text = dic[@"account"];
            }else{
                cell.commentUserName.text = dic[@"username"];
            }
            
            
            cell.posiTion.text = dic[@"posiTionName"];
            if (dic[@"posiTionName"]==nil||[dic[@"posiTionName"] isEqualToString:@"null"]) {
                cell.posiTion.text = @"";
            }
            
//            if ([dic[@"authState"] integerValue] == 2) {
//                
//                cell.authStateImageView.image = [UIImage imageNamed:@"yirenzheng"];
//            }else{
//                
//                cell.authStateImageView.image = [UIImage imageNamed:@"weirenzheng"];
//            }
            //认证
            cell.isAuthState.hidden = [UsedTool authStateImageViewHidden:dic[@"authState"]];
            //会员图标
            cell.authStateImageView.image = [UsedTool setVipimage:dic[@"vipLevel"]];
            cell.titleLabel.text = dic[@"title"];
            
            cell.priceLabel.text = [self comperNumber:dic[@"investment"]];
            
            
            
            //判断上级
            cell.companyUserName.text = [UsedTool userType:dic[@"userType"] companyName:dic[@"companyName"] userAddress:dic[@"userAddress"]];
            
            return cell;
        }else if (_currentPage == 5){//服务
            
            NSDictionary *dicData = _dataSource[indexPath.row];
            
            if ([dicData[@"userType"] integerValue] == 2) {
                
                //企业
                SoftEnterpriseCell *cell = [tableView dequeueReusableCellWithIdentifier:SoftEnterprisecell];
                if (!cell) {
                    UINib * nib4 = [UINib nibWithNibName:@"SoftEnterpriseCell" bundle:nil];//服务
                    [tableView registerNib:nib4 forCellReuseIdentifier:SoftEnterprisecell];
                    cell = [tableView dequeueReusableCellWithIdentifier:SoftEnterprisecell];
                }
                cell.titleLabel.text = dicData[@"title"];
                //设置圆形头像
                [cell.headPhoto.layer setCornerRadius:cell.headPhoto.frame.size.height/2];
                [cell.headPhoto.layer setMasksToBounds:YES];
                [cell.headPhoto setContentMode:UIViewContentModeScaleAspectFill];
                [cell.headPhoto setClipsToBounds:YES];
                cell.headPhoto.layer.shadowColor = [UIColor blackColor].CGColor;
                cell.headPhoto.layer.shadowOffset = CGSizeMake(4, 4);
                cell.headPhoto.layer.shadowOpacity = 0.5;
                cell.headPhoto.layer.shadowRadius = 2.0;
                cell.headPhoto.userInteractionEnabled = YES;
                [cell.headPhoto sd_setImageWithURL:dicData[@"headPhoto"] placeholderImage:[UIImage imageNamed:@"project_detail_taoxin_normal"]];
                
                cell.addressLabel.text = dicData[@"address"];
                
                
                //自定义的label
                UILabel *label = [[UILabel alloc] init];
                if (dicData[@"username"] == nil ||[dicData[@"username"] isEqualToString:@""]||[dicData[@"username"] isEqualToString:@"null"]) {
                    label.text = dicData[@"account"];
                }else{
                    label.text = dicData[@"username"];
                }
                label.numberOfLines = 1;
                label.font = [UIFont systemFontOfSize:17];
                label.textColor = cell.companyName.textColor;
                CGSize size = [label.text sizeWithFont:[UIFont systemFontOfSize:17] constrainedToSize:CGSizeMake(MAXFLOAT, 21)];
                if (size.width > self.width-140) {
                    size.width = self.width-140;
                }
                
                CGRect frameC = cell.companyName.frame;
                frameC.size.width = size.width;
                label.frame = frameC;
                [cell addSubview:label];
                
                UIImageView *authImageView = [[UIImageView alloc] initWithFrame:CGRectMake(label.frame.origin.x+label.frame.size.width+8, label.frame.origin.y+3, 15, 15)];
                
                
//                if ([dicData[@"authState"] integerValue] == 2) {
//                    //已认证
//                    authImageView.image = [UIImage imageNamed:@"yirenzheng"];
//                }else{
//                    
//                    authImageView.image = [UIImage imageNamed:@"weirenzheng"];
//                }
                //认证
                cell.isAuthState.hidden = [UsedTool authStateImageViewHidden:dicData[@"authState"]];
                //会员图标
                authImageView.image = [UsedTool setVipimage:dicData[@"vipLevel"]];
                [cell addSubview:authImageView];
                
                return cell;
            }else{
                //个人
                SoftwareCell *cell = [tableView dequeueReusableCellWithIdentifier:Softwarecell];
                if (!cell) {
                    UINib * nib3 = [UINib nibWithNibName:@"SoftwareCell" bundle:nil];//服务
                    [tableView registerNib:nib3 forCellReuseIdentifier:Softwarecell];
                    cell = [tableView dequeueReusableCellWithIdentifier:Softwarecell];
                }
                
                cell.titleLabel.text =dicData[@"title"];
                
                
                //设置圆形头像
                [cell.headPhotoImageView.layer setCornerRadius:cell.headPhotoImageView.frame.size.height/2];
                [cell.headPhotoImageView.layer setMasksToBounds:YES];
                [cell.headPhotoImageView setContentMode:UIViewContentModeScaleAspectFill];
                [cell.headPhotoImageView setClipsToBounds:YES];
                cell.headPhotoImageView.layer.shadowColor = [UIColor blackColor].CGColor;
                cell.headPhotoImageView.layer.shadowOffset = CGSizeMake(4, 4);
                cell.headPhotoImageView.layer.shadowOpacity = 0.5;
                cell.headPhotoImageView.layer.shadowRadius = 2.0;
                cell.headPhotoImageView.userInteractionEnabled = YES;
                
                [cell.headPhotoImageView sd_setImageWithURL:dicData[@"headPhoto"] placeholderImage:[UIImage imageNamed:@"project_detail_taoxin_normal"]];
                
                if (dicData[@"username"] == nil ||[dicData[@"username"] isEqualToString:@""]||[dicData[@"username"] isEqualToString:@"null"]) {
                    cell.commentUserName.text = dicData[@"account"];
                }else{
                    cell.commentUserName.text = dicData[@"username"];
                }
                
                cell.posiTion.text = dicData[@"posiTionName"];
                if (dicData[@"posiTionName"]==nil||[dicData[@"posiTionName"] isEqualToString:@"null"]) {
                    cell.posiTion.text = @"";
                }
                
//                if ([dicData[@"authState"] integerValue] == 2) {
//                    
//                    cell.authStateImageView.image = [UIImage imageNamed:@"yirenzheng"];
//                }else{
//                    
//                    cell.authStateImageView.image = [UIImage imageNamed:@"weirenzheng"];
//                }
                //认证
                cell.isAuthState.hidden = [UsedTool authStateImageViewHidden:dicData[@"authState"]];
                //会员图标
                cell.authStateImageView.image = [UsedTool setVipimage:dicData[@"vipLevel"]];
                //判断上级
                cell.companyUserName.text = [UsedTool userType:dicData[@"userType"] companyName:dicData[@"companyName"] userAddress:dicData[@"userAddress"]];
                return cell;
            }
            
            
        }else if(_currentPage == 6){
            BusinessActCell *cell = [tableView dequeueReusableCellWithIdentifier:BusinessActcell];
            if (!cell) {
                UINib * nib2 = [UINib nibWithNibName:@"BusinessActCell" bundle:nil];//活动
                [tableView registerNib:nib2 forCellReuseIdentifier:BusinessActcell];
                cell = [tableView dequeueReusableCellWithIdentifier:BusinessActcell];
            }
            
            NSDictionary *dicData = [NSDictionary dictionaryWithDictionary:_dataSource[indexPath.row]];
            
            [cell.photoImageView sd_setImageWithURL:[NSURL URLWithString:dicData[@"logo"]] placeholderImage:[UIImage imageNamed:@"img_normal3"]];
            cell.titleLabel.text = dicData[@"title"];
            cell.addressLabel.text = dicData[@"address"];
            //时间
            NSString *timeStr = dicData[@"createtime"];
            //年月日
            NSString *yearStr = [timeStr substringToIndex:10];
            //几点
            NSString *timeString = [timeStr substringWithRange:NSMakeRange(10,6)];
            //周几
            NSString *weekStr = [UsedTool getWeekDayForstring:timeStr];
            
            cell.timeLabel.text = [NSString stringWithFormat:@"%@ %@ %@",yearStr,weekStr,timeString];
            //标签
            NSArray *arrayLabel = [dicData[@"lable"] componentsSeparatedByString:@","];
            if (arrayLabel.count>0) {
                
                cell.labelLabel.layer.borderWidth = 0.5f;
                cell.labelLabel.layer.borderColor = RGB(23, 176, 216).CGColor;
                cell.labelLabel.backgroundColor = RGB(217, 242, 255);
                cell.labelLabel.text = arrayLabel[0];
                CGSize size = [cell.labelLabel sizeThatFits:CGSizeMake(MAXFLOAT, 18)];
                cell.labelWidthConstraint.constant = size.width +10;
                
            }
            if (arrayLabel.count>1) {
                cell.labelLabelTwo.layer.borderWidth = 0.5f;
                cell.labelLabelTwo.layer.borderColor = RGB(23, 176, 216).CGColor;
                cell.labelLabelTwo.backgroundColor = RGB(217, 242, 255);
                cell.labelLabelTwo.text = arrayLabel[1];
                CGSize sizeTwo = [cell.labelLabelTwo sizeThatFits:CGSizeMake(MAXFLOAT, 18)];
                cell.labelWidthConstraintTwo.constant = sizeTwo.width +10;
            }
            if (arrayLabel.count==1) {
                cell.labelLabelTwo.text = @"";
                cell.labelWidthConstraintTwo.constant = 0;
            }
        
            return cell;
        
        }else{              // 招标
            SearchProjectCell *cell = [tableView dequeueReusableCellWithIdentifier:SearchProjectcell];
            if (!cell) {
                UINib * nib = [UINib nibWithNibName:@"SearchProjectCell" bundle:nil];//项目
                [tableView registerNib:nib forCellReuseIdentifier:SearchProjectcell];
                cell = [tableView dequeueReusableCellWithIdentifier:SearchProjectcell];
            }
            cell.TitleLabel.text = _dataSource[indexPath.row][@"title"];
            
            cell.AddressLabel.text = _dataSource[indexPath.row][@"address"];
            
            cell.IndustryLabel.text = _dataSource[indexPath.row][@"projectType"];
            cell.PriceLabel.textColor = RGB(111, 113, 121);
            //时间换算
            NSDate *date = [CustomExcetion dateFromString:_dataSource[indexPath.row][@"createtime"]];
            [cell.investmentLabel setTextColor:RGB(111, 113, 121)];
            cell.PriceLabel.text = [CustomExcetion prettyDateWithReference:date];
            
            if ([_dataSource[indexPath.row][@"type"] isEqualToString:@"政府"]) {
                
                cell.ProjectIconImageView.image = [UIImage imageNamed:@"政府"];
            }else if ([_dataSource[indexPath.row][@"type"] isEqualToString:@"企业"]){
                
                cell.ProjectIconImageView.image = [UIImage imageNamed:@"企业"];
            }else{
                
                cell.ProjectIconImageView.image = [UIImage imageNamed:@"个人"];
            }
            return cell;
        }
    }
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];//取消选中状态
    
    //取消显示后退键文字
    UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStyleDone target:nil action:nil];
    _mainVC.navigationItem.backBarButtonItem = barButtonItem;
    
    if ([[USER_DEFAULTS objectForKey:@"usertype"] integerValue] != 1 ) {//政府 //企业
        switch (_currentPage) {
            case 0://个人
            {
                thirdPersonVC *personVC = [[thirdPersonVC alloc] init];
                personVC.userId = _dataSource[indexPath.row][@"userId"];
                personVC.userType = @"1";//个人
                [self.mainVC.navigationController pushViewController:personVC animated:YES];
            }
                break;
            case 1://企业
            {
                thirdPersonVC *personVC = [[thirdPersonVC alloc] init];
                personVC.userId = _dataSource[indexPath.row][@"userId"];
                personVC.userType = @"2";//企业
                [self.mainVC.navigationController pushViewController:personVC animated:YES];
            }
                break;
            case 2://政府
            {
                goveDetailVC *person = [[goveDetailVC alloc]init];
                person.userId = _dataSource[indexPath.row][@"userId"];
                person.userType = @"3";//企业
                person.addressStr = _dataSource[indexPath.row][@"userName"];
                self.mainVC.navigationController.navigationBar.opaque = NO;
                [self.mainVC.navigationController pushViewController:person animated:YES];
            }
                break;
            case 3://项目
            {
                
                self.isProjectOrPrice = @"项目";
                [self clickForDetails:_dataSource[indexPath.row][@"projectId"]];
//                SearchProjectInfoVC * searchVC = [[SearchProjectInfoVC alloc]init];
//                searchVC.projectId = _dataSource[indexPath.row][@"projectId"];
//                [self.mainVC.navigationController pushViewController:searchVC animated:YES];
            }
                break;
            case 4://资金
            {
                self.isProjectOrPrice = @"资金";
                [self clickForDetails:_dataSource[indexPath.row][@"fundsId"]];
//                SearchPriceDetail *searchPriceVC = [[SearchPriceDetail alloc] init];
//                searchPriceVC.fundsId = _dataSource[indexPath.row][@"fundsId"];
//                [self.mainVC.navigationController pushViewController:searchPriceVC animated:YES];
            }
                break;
            case 5://服务
            {
//                SoftwareDevelop_Detail *SoftwareDevelop_Detail = [_mainVC.storyboard instantiateViewControllerWithIdentifier:@"SoftwareDevelop_Detail"];
//                SoftwareDevelop_Detail.projectId = _dataSource[indexPath.row][@"serviceId"];
//                [_mainVC.navigationController pushViewController:SoftwareDevelop_Detail animated:YES];
                serviceInfo *serviceInfoVC = [[serviceInfo alloc] initWithNibName:@"serviceInfo" bundle:nil];
                serviceInfoVC.serviceId = _dataSource[indexPath.row][@"serviceId"];
                [self.mainVC.navigationController pushViewController:serviceInfoVC animated:YES];
            }
                break;
            case 6://活动
            {
//                BusinessActivity_Detail *business_Detail = [_mainVC.storyboard instantiateViewControllerWithIdentifier:@"business_detail"];
//                business_Detail.activityId = _dataSource[indexPath.row][@"activityId"];
//                [_mainVC.navigationController pushViewController:business_Detail animated:YES];
                BusinessActInfo *businessVC = [[BusinessActInfo alloc] init];
                businessVC.activityId = _dataSource[indexPath.row][@"activityId"];
                [self.mainVC.navigationController pushViewController:businessVC animated:YES];
            }
                break;
                case 7://招标
            {
                TrickTenderInfo *trickInfoVC = [[TrickTenderInfo alloc] init];
                trickInfoVC.userId = [USER_DEFAULTS objectForKey:@"userid"];
                trickInfoVC.bidId = _dataSource[indexPath.row][@"bidId"];
                [self.mainVC.navigationController pushViewController:trickInfoVC animated:YES];
            }
                break;
        }
    }else {
        switch (_currentPage) {
            case 0://个人
            {
//                ThirdPerson_Person *person = [self.mainVC.storyboard instantiateViewControllerWithIdentifier:@"thirdPerson"];
//                person.strUserId = _dataSource[indexPath.row][@"userId"];
//                person.strUserType = @"1";//个人
//                person.strUserName = [NSString stringWithFormat:@"%@的详情",_dataSource[indexPath.row][@"userName"]];
//                [self.mainVC.navigationController pushViewController:person animated:YES];
                thirdPersonVC *personVC = [[thirdPersonVC alloc] init];
                personVC.userId = _dataSource[indexPath.row][@"userId"];
                personVC.userType = @"1";//个人
                [self.mainVC.navigationController pushViewController:personVC animated:YES];
            }
                break;
            case 1://企业
            {
//                ThirdPerson_Company *person = [self.mainVC.storyboard instantiateViewControllerWithIdentifier:@"thirdCompany"];
//                person.strUserId = _dataSource[indexPath.row][@"userId"];
//                person.strUserType = @"2";//企业
//                person.strUserName = [NSString stringWithFormat:@"%@的详情",_dataSource[indexPath.row][@"userName"]];
//                [self.mainVC.navigationController pushViewController:person animated:YES];
                thirdPersonVC *personVC = [[thirdPersonVC alloc] init];
                personVC.userId = _dataSource[indexPath.row][@"userId"];
                personVC.userType = @"2";//企业
                [self.mainVC.navigationController pushViewController:personVC animated:YES];
            }
                break;
            case 2://政府
            {
//                ThirdPerson_Government *person = [self.mainVC.storyboard instantiateViewControllerWithIdentifier:@"thirdGovernmet"];
//                person.strUserId = _dataSource[indexPath.row][@"userId"];
//                person.strUserType = @"3";//企业
//                person.strUserName = [NSString stringWithFormat:@"%@的详情",_dataSource[indexPath.row][@"userName"]];
//                [self.mainVC.navigationController pushViewController:person animated:YES];
                
                goveDetailVC *person = [[goveDetailVC alloc]init];
                person.userId = _dataSource[indexPath.row][@"userId"];
                person.userType = @"3";//企业
                person.addressStr = _dataSource[indexPath.row][@"userName"];
                [self.mainVC.navigationController pushViewController:person animated:YES];
            }
                break;
            case 3://项目
            {
                self.isProjectOrPrice = @"项目";
                [self clickForDetails:_dataSource[indexPath.row][@"projectId"]];
                //
//                SearchProjectInfoVC * searchVC = [[SearchProjectInfoVC alloc]init];
//                searchVC.projectId = _dataSource[indexPath.row][@"projectId"];
//                [self.mainVC.navigationController pushViewController:searchVC animated:YES];
            }
                break;
            case 4://资金
            {
                self.isProjectOrPrice = @"资金";
                [self clickForDetails:_dataSource[indexPath.row][@"fundsId"]];
//                SearchPrice_Detail *SearchPrice_Detail = [_mainVC.storyboard instantiateViewControllerWithIdentifier:@"SearchPrice_Detail"];
//                SearchPrice_Detail.fundsId = _dataSource[indexPath.row][@"fundsId"];
//                [_mainVC.navigationController pushViewController:SearchPrice_Detail animated:YES];
//                SearchPriceDetail *searchPriceVC = [[SearchPriceDetail alloc] init];
//                searchPriceVC.fundsId = _dataSource[indexPath.row][@"fundsId"];
//                [self.mainVC.navigationController pushViewController:searchPriceVC animated:YES];
            }
                break;
            case 5://服务
            {
//                SoftwareDevelop_Detail *SoftwareDevelop_Detail = [_mainVC.storyboard instantiateViewControllerWithIdentifier:@"SoftwareDevelop_Detail"];
//                SoftwareDevelop_Detail.projectId = _dataSource[indexPath.row][@"serviceId"];
//                [_mainVC.navigationController pushViewController:SoftwareDevelop_Detail animated:YES];
                serviceInfo *serviceInfoVC = [[serviceInfo alloc] initWithNibName:@"serviceInfo" bundle:nil];
                serviceInfoVC.serviceId = _dataSource[indexPath.row][@"serviceId"];
                [self.mainVC.navigationController pushViewController:serviceInfoVC animated:YES];
            }
                break;
            case 6://招聘＋求职
            {
//                Recruitment_Detail *recruitment = [_mainVC.storyboard instantiateViewControllerWithIdentifier:@"recruitment_Detail"];
//                recruitment.projectId = _dataSource[indexPath.row][@"jobId"];
//                if ([[USER_DEFAULTS objectForKey:@"usertype"] integerValue] ==1 ) {//个人
//                    //招聘
//                    recruitment.strType = @"1";
//                }else if([[USER_DEFAULTS objectForKey:@"usertype"] integerValue] ==2 ){//企业
//                    //求职
//                    recruitment.strType = @"2";
//                }
//                [_mainVC.navigationController pushViewController:recruitment animated:YES];
                RecruitmentInfo *recruVC = [[RecruitmentInfo alloc] initWithNibName:@"RecruitmentInfo" bundle:nil];
                recruVC.jobId = _dataSource[indexPath.row][@"jobId"];
                [self.mainVC.navigationController pushViewController:recruVC animated:YES];
                
                
            }
                break;
            case 7://活动
            {
//                BusinessActivity_Detail *business_Detail = [_mainVC.storyboard instantiateViewControllerWithIdentifier:@"business_detail"];
//                business_Detail.activityId = _dataSource[indexPath.row][@"activityId"];
//                [_mainVC.navigationController pushViewController:business_Detail animated:YES];
                BusinessActInfo *businessVC = [[BusinessActInfo alloc] init];
                businessVC.activityId = _dataSource[indexPath.row][@"activityId"];
                [self.mainVC.navigationController pushViewController:businessVC animated:YES];
            }
                break;
            case 8:{//招标
                TrickTenderInfo *trickInfoVC = [[TrickTenderInfo alloc] init];
                trickInfoVC.userId = [USER_DEFAULTS objectForKey:@"userid"];
                trickInfoVC.bidId = _dataSource[indexPath.row][@"bidId"];
                [self.mainVC.navigationController pushViewController:trickInfoVC animated:YES];
            }
                break;
        }
    }
    
    
    
}


#pragma mark - 网络任务
- (void)startSearch
{

    //token=验证用户&page=页码&userId=用户id
    NSMutableDictionary *muDicParameters = [NSMutableDictionary dictionary];
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"userid"] forKey:@"userId"];
    [muDicParameters setObject:[USER_DEFAULTS objectForKey:@"token"] forKey:@"token"];//验证用户
    [muDicParameters setObject:[NSString stringWithFormat:@"%ld",paggge] forKey:@"page"];
    
    NSString *strURl = @"";
    if ([[USER_DEFAULTS objectForKey:@"usertype"] integerValue] != 1 ) {//政府、企业
        switch (_currentPage) {
            case 0://个人
            {
                strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"getFocus_People_app_focus.im.lensum"];
            }
                break;
            case 1://企业
            {
                strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"getFocus_Comamy_app_focus.im.lensum"];
            }
                break;
            case 2://政府
            {
                strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"getFocus_Gove_app_focus.im.lensum"];
            }
                break;
            case 3://项目
            {
                strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"getFocus_Project_app_focus.im.lensum"];
            }
                break;
            case 4://资金
            {
                strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"getFocus_Funds_app_focus.im.lensum"];
            }
                break;
            case 5://服务
            {
                strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"getFocus_Service_app_focus.im.lensum"];
            }
                break;
            case 6://活动
            {
                strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"getFocus_Activity_app_focus.im.lensum"];
            }
                break;
            case 7:{//招投标
                strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"getFocus_BidProject_app_focus.im.lensum"];
            }
                break;
        }
        
    }else {//个人
        switch (_currentPage) {
            case 0://个人
            {
                strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"getFocus_People_app_focus.im.lensum"];
            }
                break;
            case 1://企业
            {
                strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"getFocus_Comamy_app_focus.im.lensum"];
            }
                break;
            case 2://政府
            {
                strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"getFocus_Gove_app_focus.im.lensum"];
            }
                break;
            case 3://项目
            {
                strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"getFocus_Project_app_focus.im.lensum"];
            }
                break;
            case 4://资金
            {
                strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"getFocus_Funds_app_focus.im.lensum"];
            }
                break;
            case 5://服务
            {
                strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"getFocus_Service_app_focus.im.lensum"];
            }
                break;
            case 6://招聘
            {
                strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"getFocus_Jobhunting_app_focus.im.lensum"];
                
                [muDicParameters setObject:@"1" forKey:@"type"];
                
                
            }
                break;
            case 7://活动
            {
                strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"getFocus_Activity_app_focus.im.lensum"];
            }
                break;
                case 8://招标
            {
                strURl = [NSString stringWithFormat:@"%@%@",URL_DEFINE,@"getFocus_BidProject_app_focus.im.lensum"];
            }
                break;
        }
    }
    
    
    
    
    AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
    [manager POST:strURl parameters:muDicParameters progress:^(NSProgress * _Nonnull uploadProgress) {
        
    } success:^(NSURLSessionDataTask * _Nonnull task, id  _Nullable responseObject) {
        UITableView *_mainTableView = _scrollTableViews[_currentPage%2];
        [_mainTableView.mj_header endRefreshing];
        NSDictionary *dicInfo = [NSDictionary dictionaryWithDictionary:responseObject];
        //NSLog(@"%@",dicInfo);
        if ([[dicInfo objectForKey:@"result"] integerValue] == 1) {
            [_mainTableView.mj_header endRefreshing];
            if (paggge == 1) {
                _dataSource = [NSMutableArray arrayWithArray:[dicInfo objectForKey:@"data"][@"record"]];
                
                if (_dataSource.count == 10) {
                    _mainTableView.mj_footer.hidden = NO;
                }else {
                    _mainTableView.mj_footer.hidden = YES;
                }
                
            }else {
                NSArray *ary11 = [dicInfo objectForKey:@"data"][@"record"];
                for (int i = 0; i<ary11.count; i++) {
                    NSDictionary *dic1 = ary11[i];
                    [_dataSource addObject:dic1];
                }
                if (ary11.count == 10) {
                    _mainTableView.mj_footer.hidden = NO;
                }else {
                    _mainTableView.mj_footer.hidden = YES;
                }
                
            }
            
            
            [_mainTableView reloadData];

        }else {
            if (paggge == 1) {
                _dataSource = [NSMutableArray array];
            }
            
            [_mainTableView reloadData];
            [_mainTableView.mj_header endRefreshing];
            [_mainTableView.mj_footer endRefreshing];


        }
        
        [self hideBubble];
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        UITableView *_mainTableView = _scrollTableViews[_currentPage%2];
        [_mainTableView.mj_header endRefreshing];
        [_mainTableView.mj_footer endRefreshing];
        if (paggge == 1) {
            _dataSource = [NSMutableArray array];
            [_mainTableView reloadData];
        }
  

    }];
}

-(NSString *)comperNumber:(NSString *)number
{
    CGFloat num1 = [number floatValue];
    NSString *strNum = @"";
    
    if (num1 >= 100000000) {
        
        strNum = [NSString stringWithFormat:@"%.2f亿",num1/100000000];
    }else if (num1<100000000 && num1>=10000){
        
        strNum = [NSString stringWithFormat:@"%.2f万",num1/10000];
    }else{
        
        strNum = [NSString stringWithFormat:@"%.2f元",num1];
    }
    return strNum;
}

#pragma mark - ＊＊＊＊＊支付＊＊＊＊＊
//点击查看详细（项目or资金）
- (void)clickForDetails:(NSString *)resId{
    if (allConstMemberid) {
        [self showRoundProgressWithTitle:@"请稍后..."];
        
        NSMutableDictionary * dict = [NSMutableDictionary dictionary];
        NSString *strData = @"";
        if ([self.isProjectOrPrice isEqualToString:@"项目"]){
            dict[@"projectId"] = resId;
            strData = @"projectDetail_app_project.im";
        }else if ([self.isProjectOrPrice isEqualToString:@"资金"]){
            dict[@"fundsId"] = resId;
            strData = @"fundsDetail_app_funds.im";
        }else{}
        
        if ([USER_DEFAULTS objectForKey:@"userid"] != nil) {
            dict[@"userId"] = [USER_DEFAULTS objectForKey:@"userid"];
        }
        
        
       
        [LSHttpTool sendHttpData:strData params:dict success:^(id responseObject) {
            NSDictionary *dicInfo = [NSDictionary dictionaryWithDictionary:responseObject];
            
            if ([[dicInfo objectForKey:@"result"] integerValue] == 1) {
                
                [self.LSPromptAlert dismissViewControllerAnimated:YES completion:nil];
                if ([self.isProjectOrPrice isEqualToString:@"项目"]) {//项目
                    SearchProjectInfoVC * SeaVC = [[SearchProjectInfoVC alloc]initWithNibName:@"SearchProjectInfoVC" bundle:nil];
                    SeaVC.dataDict = dicInfo[@"data"];
                    SeaVC.projectData = [NSMutableArray arrayWithArray:dicInfo[@"data"][@"commentsList"]];
                    
                    [self.mainVC.navigationController pushViewController:SeaVC animated:YES];
                }else if([self.isProjectOrPrice isEqualToString:@"资金"]){//资金
                    SearchPriceDetail *Svc = [[SearchPriceDetail alloc] initWithNibName:@"SearchPriceDetail" bundle:nil];
                    
                    Svc.dicData = dicInfo[@"data"];
                    Svc.commentsList = dicInfo[@"data"][@"commentsList"];
                    
                    [self.mainVC.navigationController pushViewController:Svc animated:YES];
                }else{
                }
               
                
            }else if ([[dicInfo objectForKey:@"result"] integerValue] == 2){

               [self showSingleIconBubble:[dicInfo objectForKey:@"msg"]];
                
            }else if ([[dicInfo objectForKey:@"result"]integerValue] == 3){
                
                isSetPayPass = [dicInfo[@"data"][@"isSetPayPass"] boolValue];
                price = [dicInfo[@"data"][@"powerMoney"]floatValue];
                
                projectId = resId;
                self.LSPromptAlert.modalPresentationStyle=UIModalPresentationOverCurrentContext;
                [self.mainVC presentViewController:self.LSPromptAlert animated:YES completion:nil];
                
            }
            
            [self hideBubble];
        } failure:^(NSError *error) {

            [self showSingleIconBubble:@"网络连接错误"];
            
        }];
        
    }else{
        
        UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"提示" message:@"请先登录" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"登录", nil];
        
        alert.tag = 10;
        
        [alert show];
        
    }

}


#pragma mark - 弹框按钮监听
//跳转会员界面
-(void)clickBecomeVIPBtn{
    
    [self.LSPromptAlert dismissViewControllerAnimated:YES completion:nil];
    
    LSBecomeVIPVC * LSBecomeVIP = [[LSBecomeVIPVC alloc]init];
    [self.mainVC.navigationController pushViewController:LSBecomeVIP animated:YES];
    
}


#pragma mark - 支付回调通知
-(void)clickAlipayBtn{
    if ([self.isProjectOrPrice isEqualToString:@"项目"]) {
        or_Number = [LSAlipay alipay:@"乐商网" body:@"项目详情" price:0.01f];
    }else if([self.isProjectOrPrice isEqualToString:@"资金"]){
        or_Number = [LSAlipay alipay:@"乐商网" body:@"资金详情" price:0.01f];
    }else{
        or_Number = nil;
    }
}

-(void)presentFailedView{
    
    // 跳转至支付失败页面
    LSPayResultVC * LSPayResult = [[LSPayResultVC alloc]init];
    [LSPayResult setCashTypeWithCashFailed];
    [self.mainVC.navigationController pushViewController:LSPayResult animated:YES];
    
}

-(void)presentView{
    
    [self.LSPromptAlert dismissViewControllerAnimated:YES completion:nil];
    [self showRoundProgressWithTitle:@"请稍后..."];
    
    NSMutableDictionary * dic = [NSMutableDictionary  dictionary];
    dic[@"token"] = allConstMemberToken;
    dic[@"payUserId"] = allConstMemberid;
    dic[@"payWay"] = @"2";
    dic[@"payMoney"] = @(price);
    dic[@"resId"] = projectId;
    dic[@"order_no"] = or_Number;
    NSString *strData = @"";
    if ([self.isProjectOrPrice isEqualToString:@"项目"]) {
        strData = @"buyProjectDetail_app_pay.im.lensum";
    }else if([self.isProjectOrPrice isEqualToString:@"资金"]){
        strData = @"buyFundsDetail_app_pay.im.lensum";
    }else{
        strData = @"";
    }
    
    [LSHttpTool sendHttpData:strData params:dic success:^(id responseObject) {
        
        NSDictionary *dicInfo = [NSDictionary dictionaryWithDictionary:responseObject];
        
        [self.LSPromptAlert dismissViewControllerAnimated:YES completion:nil];
        
        if ([[dicInfo objectForKey:@"result"] integerValue] == 1) {
            
            NSMutableDictionary * dict = [NSMutableDictionary dictionary];
            if ([self.isProjectOrPrice isEqualToString:@"项目"]) {
                dict[@"projectId"] = dic[@"resId"];
            }else if([self.isProjectOrPrice isEqualToString:@"资金"]){
                dict[@"fundsId"] = dic[@"resId"];
            }
            if ([USER_DEFAULTS objectForKey:@"userid"] != nil) {
                dict[@"userId"] = [USER_DEFAULTS objectForKey:@"userid"];
            }
            NSString *dataStr = @"";
            if ([self.isProjectOrPrice isEqualToString:@"项目"]) {
                dataStr = @"projectDetail_app_project.im";
            }else if ([self.isProjectOrPrice isEqualToString:@"资金"]){
                dataStr = @"fundsDetail_app_funds.im";
            }else{
                dataStr = @"";
            }
            [LSHttpTool sendHttpData:dataStr params:dict success:^(id responseObject) {
                if ([[dicInfo objectForKey:@"result"] integerValue] == 1) {
                    if ([self.isProjectOrPrice isEqualToString:@"项目"]) {
                        SearchProjectInfoVC * SeaVC = [[SearchProjectInfoVC alloc]initWithNibName:@"SearchProjectInfoVC" bundle:nil];
                        SeaVC.dataDict = responseObject[@"data"];
                        SeaVC.projectData = [NSMutableArray arrayWithArray:responseObject[@"data"][@"commentsList"]];
                        
                        [self.mainVC.navigationController pushViewController:SeaVC animated:YES];
                    }else if([self.isProjectOrPrice isEqualToString:@"资金"]){
                        SearchPriceDetail *Svc = [[SearchPriceDetail alloc] initWithNibName:@"SearchPriceDetail" bundle:nil];
                        
                        Svc.dicData = responseObject[@"data"];
                        Svc.commentsList = responseObject[@"data"][@"commentsList"];
                        [self.mainVC.navigationController pushViewController:Svc animated:YES];
                    }else{}
                    
                    
                    [self hideBubble];
                    
                }else{

                    [self showSingleIconBubble:[responseObject objectForKey:@"msg"]];
                    
                }
                
            } failure:^(NSError *error) {

                [self showSingleIconBubble:@"网络连接错误"];
                
            }];
            
        }else{

            [self showSingleIconBubble:[dicInfo objectForKey:@"msg"]];
            
        }
        
    } failure:^(NSError *error) {
        
        // 跳转至支付成功页面
        LSPayResultVC * LSPayResult = [[LSPayResultVC alloc]init];
        [LSPayResult setCashTypeWithExchangeFailed];
        
        [self hideBubble];
    }];
    
}

#pragma mark - 余额支付
-(void)clickCashBtn{
    
    NSString * balanceStr = [self.LSPromptAlert.PromptAlertView.balanceLabel.text stringByReplacingOccurrencesOfString:@"￥"withString:@""];
    
    double balance = [balanceStr floatValue];
    
    if (balance < 1) {
        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"支付失败"
                                                        message:@"余额不足！"
                                                       delegate:self
                                              cancelButtonTitle:@"取消"
                                              otherButtonTitles:@"立刻充值",nil];
        alert.tag = 20;
        [alert show];
        
    }else{
        
        if (isSetPayPass) {
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"支付失败"
                                                            message:@"未设置支付密码"
                                                           delegate:self
                                                  cancelButtonTitle:@"取消"
                                                  otherButtonTitles:@"立即设置",nil];
            alert.tag = 30;
            [alert show];
            
        }else{
            
            UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"余额支付" message:nil delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:@"确定",nil];
            alert.alertViewStyle = UIAlertViewStylePlainTextInput;
            
            UITextField *title = [alert textFieldAtIndex:0];
            [title setSecureTextEntry:YES];
            title.borderStyle = UITextBorderStyleNone;
            title.textColor = [UIColor redColor];
            title.textAlignment = NSTextAlignmentCenter;
            title.font = [UIFont systemFontOfSize:16.0f];
            title.placeholder = @"请输入支付密码";
            
            
            [alert showAlertWithCompletionHandler:^(NSInteger buttonIndex) {
                if(buttonIndex == 1){
                    UITextField *tf=[alert textFieldAtIndex:0];
                    if (tf.text.length > 0) {
                        
                        [self showRoundProgressWithTitle:@"请稍后..."];
                        
                        NSMutableDictionary * dic = [NSMutableDictionary  dictionary];
                        dic[@"token"] = allConstMemberToken;
                        dic[@"payUserId"] = allConstMemberid;
                        dic[@"payWay"] = @"1";
                        dic[@"payMoney"] = @(price);
                        dic[@"resId"] = projectId;
                        dic[@"payPass"] = tf.text;
                        NSString *strData = @"";
                        if ([self.isProjectOrPrice isEqualToString:@"项目"]) {
                            strData = @"buyProjectDetail_app_pay.im.lensum";
                        }else if([self.isProjectOrPrice isEqualToString:@"资金"]){
                            strData = @"buyFundsDetail_app_pay.im.lensum";
                        }else{}
                        [LSHttpTool sendHttpData:strData params:dic success:^(id responseObject) {
                            
                            [self.LSPromptAlert dismissViewControllerAnimated:YES completion:nil];
                            
                            NSDictionary *dicInfo = [NSDictionary dictionaryWithDictionary:responseObject];
                            if ([[dicInfo objectForKey:@"result"] integerValue] == 1) {
                                
                                NSMutableDictionary * dict = [NSMutableDictionary dictionary];
                                if ([self.isProjectOrPrice isEqualToString:@"项目"]) {
                                    dict[@"projectId"] = dic[@"resId"];
                                }else if ([self.isProjectOrPrice isEqualToString:@"资金"]){
                                    dict[@"fundsId"] = dic[@"resId"];
                                }else{}
                                if ([USER_DEFAULTS objectForKey:@"userid"] != nil) {
                                    dict[@"userId"] = [USER_DEFAULTS objectForKey:@"userid"];
                                }
                                
                                NSString *dataStr = @"";
                                if ([self.isProjectOrPrice isEqualToString:@"项目"]) {
                                    dataStr = @"projectDetail_app_project.im";
                                }else if([self.isProjectOrPrice isEqualToString:@"资金"]){
                                    dataStr = @"fundsDetail_app_funds.im";
                                }else{}
                                [LSHttpTool sendHttpData:dataStr params:dict success:^(id responseObject) {
                                    if ([[dicInfo objectForKey:@"result"] integerValue] == 1) {
                                        if ([self.isProjectOrPrice isEqualToString:@"项目"]) {
                                        SearchProjectInfoVC * SeaVC = [[SearchProjectInfoVC alloc]initWithNibName:@"SearchProjectInfoVC" bundle:nil];
                                        SeaVC.dataDict = responseObject[@"data"];
                                        SeaVC.projectData = [NSMutableArray arrayWithArray:responseObject[@"data"][@"commentsList"]];
                                        
                                        [self.mainVC.navigationController pushViewController:SeaVC animated:YES];
                                        }else if ([self.isProjectOrPrice isEqualToString:@"资金"]){
                                            SearchPriceDetail *Svc = [[SearchPriceDetail alloc] initWithNibName:@"SearchPriceDetail" bundle:nil];
                                            
                                            Svc.dicData = responseObject[@"data"];
                                            Svc.commentsList = responseObject[@"data"][@"commentsList"];
                                            [self.mainVC.navigationController pushViewController:Svc animated:YES];
                                        }else{}
                                        [self hideBubble];
                                        
                                    }else{
                                        [self showSingleIconBubble:[responseObject objectForKey:@"msg"]];
                                    }
                                    
                                } failure:^(NSError *error) {

                                    [self showSingleIconBubble:@"网络连接错误"];
                                    
                                }];
                                
                            }else{

                               [self showSingleIconBubble:[dicInfo objectForKey:@"msg"]];
                                
                            }
                            
                            
                        } failure:^(NSError *error) {
                            
                            // 跳转至支付成功页面
                            LSPayResultVC * LSPayResult = [[LSPayResultVC alloc]init];
                            [LSPayResult setCashTypeWithCashFailed];
                            
                            [self hideBubble];
                        }];
                        
                    }else{
                        
                        NSString *strMsg = @"密码不能为空";
                        
                        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"提示" message:strMsg delegate:self cancelButtonTitle:@"知道了" otherButtonTitles:nil, nil];
                        [alert show];
                        
                    }
                }
            }];
            
            
        }
        
    }
    
}

#pragma mark - alertview

-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
    if (buttonIndex == 1) {
        [self.LSPromptAlert dismissViewControllerAnimated:YES completion:nil];
        
        UIStoryboard *LoginAndRegister = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
        UINavigationController *loginNAV = [LoginAndRegister instantiateViewControllerWithIdentifier:@"LoginNav"];
        //充值
        LSRechargeVC * LSRecharge = [[LSRechargeVC alloc]init];
        
        switch (alertView.tag) {
            case 10:
                
                [self.mainVC presentViewController:loginNAV animated:YES completion:nil];
                
                break;
                
            case 20:
                
                [self.mainVC.navigationController pushViewController:LSRecharge animated:YES];
                
                break;
                
            case 30:
            {
                
                UIStoryboard *LoginAndRegister = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
                ForgetPassWord *ForgetPassWord = [LoginAndRegister instantiateViewControllerWithIdentifier:@"forgetpassword"];
                ForgetPassWord.titleStr = @"修改支付密码";
                [self.mainVC.navigationController pushViewController:ForgetPassWord animated:YES];
                
            }
                break;
                
            default:
                break;
        }
    }
    
    
}


@end
